/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.alphawavesgames.engine.maths;

/**
 *
 * @author duncan
 * 2 float component vector
 */
public class Vector2 
{
    protected float m_x;
    protected float m_y;

    public Vector2()
    {
        m_x = m_y = 0.0f;
    }

    public Vector2( float initAll )
    {
        m_x = m_y = initAll;
    }

    public Vector2( float x, float y )
    {
        m_x = x;
        m_y = y;
    }

    public Vector2( Vector2 vec2 )
    {
        m_x = vec2.m_x;
        m_y = vec2.m_y;
    }


    public void setX( float x ) { m_x = x; }
    public void setY( float y ) { m_y = y; }
    public float getX() { return m_x; }
    public float getY() { return m_y; }

    public Vector2 add( Vector2 otherVec )
    {
        m_x += otherVec.m_x;
        m_y += otherVec.m_y;
        return this;
    }

    public Vector2 sub( Vector2 otherVec )
    {
        m_x -= otherVec.m_x;
        m_y -= otherVec.m_y;
        return this;
    }

    public Vector2 componentMul( Vector2 otherVec )
    {
        m_x *= otherVec.m_x;
        m_y *= otherVec.m_y;
        return this;
    }

    public Vector2 scalarMul( float scalar )
    {
        m_x *= scalar;
        m_y *= scalar;
        return this;
    }

    public Vector2 componentDiv( Vector2 otherVec )
    {
        m_x /= otherVec.m_x;
        m_y /= otherVec.m_y;
        return this;
    }

    public Vector2 scalarDiv( float scalar )
    {
        m_x /= scalar;
        m_y /= scalar;
        return this;
    }

    public float dot( Vector2 otherVec )
    {
        return (m_x * otherVec.m_x) + (m_y * otherVec.m_y);
    }


}
